<?php

namespace app\common\model;

use think\Model;


class Join extends Model
{

    

    

    // 表名
    protected $table = 'join';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_text'
    ];



    public function getTypeList()
    {
        return ['0'=>'供需', '1'=>'成员'];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ?: ($data['type'] ?? '');
        $list = $this->getTypeList();
        return $list[$value] ?? '';
    }
    

    







    public function need()
    {
        return $this->belongsTo('Need', 'need_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function member()
    {
        return $this->belongsTo('Member', 'need_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function users()
    {
        return $this->belongsTo('Users', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
